// component/orderbox/orderbox.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    list:{
      type:Array
    },
    title:{type:JSON}
  },
  options: {
    addGlobalClass: true,
  },
  /**
   * 组件的初始数据
   */
  data: {
    active:1,
    checked: false,
    result: [],
    arr:[]
  },
  /**
   * 组件的方法列表
   */
  methods: {
    //跳转
    urgeUser(e){//服务催促
      console.log(e.currentTarget.dataset.phone)
      let telphone = e.currentTarget.dataset.phone;
      if(!telphone){
        wx.showToast({
          title: '该订单没有用户信息！',
          icon: 'none',
          duration: 2000
        })
        return
      }else{
        wx.makePhoneCall({
          phoneNumber: telphone
        })
      }
    },
    serviceRouter(e){
      //订单编号
      let type = e.currentTarget.dataset.type;
      let time = e.currentTarget.dataset.time;
      let markName = e.currentTarget.dataset.markname;
      let telphone = e.currentTarget.dataset.telphone;
      // console.log(markName,telphone,e.currentTarget.dataset, "========11===")
      wx.navigateTo({
        url: e.currentTarget.dataset.orderid+'&type='+type+'&time='+time+'&telphone='+telphone+'&markName='+markName
      })
    },
    onChange(event) {
      this.setData({
        result: event.detail,
      });
      this.triggerEvent('onChange',event.detail);
      // console.log(event.detail)
    },
    del(){
      this.setData({
        result:[]
      })
    },
    queryall(){
      this.properties.list.forEach(element => {
        // this.data.arr.push(element.id.toString());
        this.data.arr.push(element.telphone);
      });
      this.setData({
        result:this.quchong(this.data.arr)
      })
      console.log(this.data.result);
    },
    quchong(arr){
      var tempArr = []; //返回的值
      var indexArr= []; //返回的索引
        for (var i = 0; i < arr.length; i++) {
          if (tempArr.indexOf(arr[i]) == -1) {
            tempArr.push(arr[i]);
            indexArr.push(i)
          } else if (tempArr.indexOf(arr[i])>=0){
            for(var j = 0;j<tempArr.length;j++){
            if (tempArr[j] == arr[i]) {
              tempArr.splice(j, 1, tempArr[j]);
              indexArr.splice(j, 1, i);
            }
          }
        }
      }
      return tempArr
    },
  },
})
